package com.example.blades.mymusicservice;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class simplePlay extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple_play);

        Button btn_play=(Button)findViewById(R.id.btn_play);
        Button btn_stop=(Button)findViewById(R.id.btn_stop);
        btn_play.setOnClickListener(startIt);
        btn_stop.setOnClickListener(stopIt);
    }

    private View.OnClickListener startIt=new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*相对于Intent i=new Intent(this,"com.studio.android.START_AUDIO_SERVICE");
            * this.startService(i);*/
            startService(new Intent("com.studio.android.START_AUDIO_SERVICE"));
        }
    };

    private View.OnClickListener stopIt=new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            stopService(new Intent("com.studio.android.START_AUDIO_SERVICE"));
            finish();
        }
    };
}